function add(){
    let uphone = document.querySelector("#uphone").value;
    let nickname = document.querySelector("#nickname").value;
    let uname = document.querySelector("#uname").value;
    let sex = document.querySelector("#sex").value;
    let birth = document.querySelector("#birth").value;
    let account = document.querySelector("#account").value;
    let upwd = document.querySelector("#password").value;


    let tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
    let name = /^[\u4e00-\u9fa5]{2,12}$/;
    let pwd = /^(?=.*[a-zA-Z]).{1,9}$/;
    if(uphone.length<=0||nickname.length<=0||uname.length<=0||birth.length<=0||account.length<=0||upwd.length<=0){
        alert("您还有信息未填写完成！")
    }else {
        if (!tel.test(uphone)) {
            alert("请填写正确的电话号码")
        } else {
            if (!name.test(uname)) {
                alert("请填写正确的名字")
            } else {
                if (!pwd.test(upwd)) {
                    alert("密码至少包含一个字母并且长度只能为9个字符")
                } else {
                  if (uphone!=account){
                      alert("您的手机号码和账号请保持一致")
                  }else {
                      $.ajax({
                          url: "/enroll",
                          type: "post",
                          data: {
                              nickname, uname, sex, uphone, birth, account, upwd
                          },
                          success: (resp) => {
                              if (resp > 0) {
                                  location.href = "/login";
                              } else {
                                  alert("注册失败,该手机号已被注册！！！");
                                  console.log("resp=" + resp)
                              }
                          }
                      })
                  }
                }
            }
        }
    }



}
function isnull(){
    location.href="/login"
}
function iscart(){
    location.href="/goods"
}
function longin(){
    $.ajax({
        url:"/enroll",
        type: "get",
        data: {

        },
        complete:function (){
            location.href="/login";
        }
    })
}